package com.yanqu.road.entity.rank.cross;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.player.UserBaseInfo;

import java.math.BigInteger;
import java.util.Objects;

public class CrossUserRank extends DataObject {

    private int bigRankType;

    private int type;                             //排行榜类型

    private int rank;                             //名次

    private long userId;                          //玩家Id

    private UserBaseInfo userBaseInfo = new UserBaseInfo();

    private long lastUpdateTime;                  //最后一次更新时间

    private BigInteger value = BigInteger.ZERO;  //排名数据

    private String param = "";

    private boolean delete = false;                 // 是否删除

    public int getType() {
        return type;
    }

    public void setType(int type) {
        if(this.type != type) {
            this.type = type;
            setUpdateOption();
        }
    }

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        if(this.rank != rank) {
            this.rank = rank;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public UserBaseInfo getUserBaseInfo() {
        return userBaseInfo;
    }

    public String getUserBaseInfoJsonStr(){
        if(null == userBaseInfo){
            return "{}";
        }else {
            return JSON.toJSONString(userBaseInfo);
        }
    }

    public void setUserBaseInfo(UserBaseInfo userBaseInfo) {
        this.userBaseInfo = userBaseInfo;
        setUpdateOption();
    }

    public BigInteger getValue() {
        return value;
    }

    public void setValue(BigInteger value) {
        if(!Objects.equals(this.value, value)) {
            this.value = value;
            setUpdateOption();
        }
    }

    public long getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(long lastUpdateTime) {
        if(this.lastUpdateTime != lastUpdateTime) {
            this.lastUpdateTime = lastUpdateTime;
            setUpdateOption();
        }
    }

    public int getBigRankType() {
        return bigRankType;
    }

    public void setBigRankType(int bigRankType) {
        if (this.bigRankType != bigRankType) {
            this.bigRankType = bigRankType;
            setUpdateOption();
        }

    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        if (param == null) {
            return;
        }
        if (!this.param.equals(param)) {
            this.param = param;
            setUpdateOption();
        }

    }

    public CrossUserRank clone(){
        CrossUserRank userRank = new CrossUserRank();
        userRank.setType(type);
        userRank.setUserId(userId);
        userRank.setUserBaseInfo(userBaseInfo);
        userRank.setValue(value);
        userRank.setLastUpdateTime(lastUpdateTime);
        userRank.setBigRankType(bigRankType);
        userRank.setParam(param);
        userRank.setDelete(delete);
        return userRank;
    }

    public boolean isDelete() {
        return delete;
    }

    public void setDelete(boolean delete) {
        if (this.delete != delete) {
            this.delete = delete;
            setUpdateOption();
        }
    }

    public static void main(String[] args) {

        //CrossUserRank
    }
}
